import { UPDATE_CABINETS_LIST, CABINET_DETAIL_PENDING, CABINET_DETAIL_RESOLVE, CABINET_DETAIL_REJECT } from './../constants/cabinets';

const INITIAL_STATE = {
  cabinet: {
    photo: '',
    tel: '',
    openTime: '',
    closeTime: '',
    place: {
      address: ''
    }
  },
  cabinets: [],
  detailLogin: false
}

export default function cabinets (state = INITIAL_STATE, action) {
  switch (action.type) {
    case UPDATE_CABINETS_LIST:
      return{
        ...state,
        cabinets: action.cabinets
      }
      break
    case CABINET_DETAIL_PENDING:
      return {
        ...state,
        detailLogin: true
      }
      break
    case CABINET_DETAIL_RESOLVE:
      return {
        ...state,
        detailLogin: false,
        cabinet: action.cabinet
      }
      break
    case CABINET_DETAIL_REJECT:
      return {
        ...state,
        detailLogin: false
      }
      break
    default:
      return state
      break
  }
}